import 'package:chop/common/DioUtils.dart';
import 'package:chop/common/MessageUtils.dart';
import 'package:chop/common/SPUtils.dart';
import 'package:chop/common/StringUtils.dart';
import 'package:chop/view/home/home_page.dart';
import 'package:chop/widgets/TextSizeWidget.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

void main() {
  DioUtils.initDioOptions();
  runApp(MyApp());
  MsgUtils.initSocket();
}


class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String room;

  @override
  initState() {
    // TODO: implement initState
    getRoom();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
//      debugShowCheckedModeBanner: false,
      navigatorKey: Get.key,
      home: getBody(),
//      home: Container(child: FixedSizeText("asdadasfasdfasd"),),
    );
  }

  getBody() {
    print("---------$room");
    if (StringUtils.isNull(room)) {
      return Container();
    } else if (room == "0") {
      return homePage();
    } else if (room == "1") {
//      return Driverhome();
      return Container();
    } else {
      print(room);
      SPUtils.save("room", "0");
      return homePage();
    }
  }

  getRoom() {
    SPUtils.get("room").then((result) {
      setState(() {
        print("result_____$result");
        room = "${result ?? 0}" == "" ? "0" : "${result ?? 0}";
      });
    });
  }

  @override
  void dispose() {
    MsgUtils.colseChannel();
    // TODO: implement dispose
    super.dispose();
  }
}
